package lesson1;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class Demo1 {
    public static void main(String[] args) {
        //System.out.println(Math.sin(Math.toRadians(180)));
        LocalDate nowDate = LocalDate.now();
        System.out.println("今天的日期：" + nowDate);//今天的日期：2018-09-06
        int year = nowDate.getYear();//年：一般用这个方法获取年
        System.out.println("year：" + year);//year：2018
        int month = nowDate.getMonthValue();//月：一般用这个方法获取月
        System.out.println("month：" + month);//month：9
        int day = nowDate.getDayOfMonth();//日：当月的第几天，一般用这个方法获取日
        System.out.println("day：" + day);//day：6

        int dayOfYear = nowDate.getDayOfYear();//日：当年的第几天
        System.out.println("dayOfYear：" + dayOfYear);//dayOfYear：249

        //星期
        System.out.println(nowDate.getDayOfWeek());//THURSDAY
        System.out.println(nowDate.getDayOfWeek().getValue());//4
        //月份
        System.out.println(nowDate.getMonth());//SEPTEMBER
        System.out.println(nowDate.getMonth().getValue());//9

        System.out.println("*************LocatTime*****************");
        LocalTime nowTime = LocalTime.now();
        System.out.println("今天的时间：" + nowTime);//今天的时间：15:33:56.749
        int hour = nowTime.getHour();//时
        System.out.println("hour：" + hour);//hour：15
        int minute = nowTime.getMinute();//分
        System.out.println("minute：" + minute);//minute：33
        int second = nowTime.getSecond();//秒
        System.out.println("second：" + second);//second：56

        int nano = nowTime.getNano();//纳秒
        System.out.println("纳秒：" + nano);//nano：749000000
        System.out.println("***************LocalDateTime*********************");
        LocalDateTime nowDateTime = LocalDateTime.now();
        System.out.println("今天是：" + nowDateTime);//今天是：2018-09-06T15:33:56.750
        System.out.println(nowDateTime.getYear());//年
        System.out.println(nowDateTime.getMonthValue());//月
        System.out.println(nowDateTime.getDayOfMonth());//日
        System.out.println(nowDateTime.getHour());//时
        System.out.println(nowDateTime.getMinute());//分
        System.out.println(nowDateTime.getSecond());//秒
        System.out.println(nowDateTime.getNano());//纳秒
        //日：当年的第几天
        System.out.println("dayOfYear：" + nowDateTime.getDayOfYear());//dayOfYear：249
        //星期
        System.out.println(nowDateTime.getDayOfWeek());//THURSDAY
        System.out.println(nowDateTime.getDayOfWeek().getValue());//4
        //月份
        System.out.println(nowDateTime.getMonth());//SEPTEMBER
        System.out.println(nowDateTime.getMonth().getValue());//9
    }
}
